/**
 * Copyright 2018 
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.dream.inspect.modules.sys.controller;


import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.dream.inspect.common.annotation.SysLog;
import com.dream.inspect.common.utils.PageUtils;
import com.dream.inspect.common.utils.R;
import com.dream.inspect.common.utils.StringUtil;
import com.dream.inspect.modules.sys.service.AuditApplyService;

/**
 * 系统用户
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2016年10月31日 上午10:40:10
 */
@RestController
@CrossOrigin
@RequestMapping("/sys/apply")
public class AuditApplyController extends AbstractController {
	@Autowired
	private AuditApplyService auditApplyService;
	
	/**
	 * 所有用户列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("sys:apply:list")
	public R list(@RequestParam Map<String, Object> params){
		PageUtils page = auditApplyService.queryPage(params);

		return R.ok().put("page", page);
	}
	
	
	
	/**
	 * 修改用户
	 */
	@SysLog("修改用户")
	@RequestMapping("/apply")
	@RequiresPermissions("sys:apply:apply")
	public R apply(@RequestParam Map<String, Object> params){
		if(StringUtil.isEmpty(params.get("ids") + "")){
			return R.error("请选择审核对象!");
		}
		params.put("auditId", getUserId());
		auditApplyService.apply(params);
		
		return R.ok();
	}

}
